package com.iisigroup.http.test;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.io.FileUtils;

/**
 * The Class MainReader.
 * 將log紀錄進行分析
 */
public class MainReader {
	
	/** The regular express. */
	private  static String regularExpress ="\\[pool-\\d*-thread-\\d*\\].*com.iisigroup.http.test.App5\\D\\-\\D(\\d*)";
	
	/**
	 * The main method.
	 *
	 * @param args the arguments
	 */
	public static void main(final String[] args){
		try {
			final	List<String> lines = FileUtils.readLines(new File("/home/weblogic/Desktop/2014_1023_input"));
			for(String line : lines){
				System.out.println(extract(line));
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	/**
	 * Extract.
	 *
	 * @param line the line
	 * @return the string
	 */
	public static  String extract(String line){
		 final Matcher matcher = Pattern.compile(regularExpress).matcher(line);
		 while(matcher.find()){
			 return  matcher.group(matcher.groupCount());
		 }
		 return null;
	}
}
